@@ -1,7 +1,15 @@ |
||
| 1 | 1 |
class AdoptXpathInWebsiteAgent < ActiveRecord::Migration |
| 2 |
+ class Agent < ActiveRecord::Base |
|
| 3 |
+ include JSONSerializedField |
|
| 4 |
+ json_serialize :options |
|
| 5 |
+ end |
|
| 6 |
+ |
|
| 2 | 7 |
def up |
| 3 | 8 |
Agent.where(type: 'Agents::WebsiteAgent').each do |agent| |
| 4 |
- next if agent.extraction_type == 'json' |
|
| 9 |
+ extract = agent.options['extract'] |
|
| 10 |
+ next unless extract.is_a?(Hash) && extract.all? { |name, detail|
|
|
| 11 |
+ detail.key?('xpath') || detail.key?('css')
|
|
| 12 |
+ } |
|
| 5 | 13 |
|
| 6 | 14 |
agent.options_will_change! |
| 7 | 15 |
agent.options['extract'].each { |name, extraction|
|